<template>
  <div class="app-container">
    <el-form
      :model="form"
      label-position="left"
      style="width: 500px; margin: 0 auto"
      label-width="120px"
    >
      <el-form-item label="选择币种">
        <el-select
          v-model="form.assetId"
          placeholder="请选择币种"
          style="width: 330px"
        >
          <el-option
            v-for="(item, index) in dataList"
            :key="index"
            :label="item.coinCode"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="数量">
        <el-input
          v-model="form.amount"
          placeholder="请输入数量"
          style="width: 330px"
        />
      </el-form-item>
      <el-form-item label="备注">
        <el-input
          v-model="form.remark"
          placeholder="请输入备注"
          type="textarea"
          :rows="5"
          style="width: 330px"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="save">确认扣除</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { settings, sysConfigUpdate } from '../../../api/order'

import { getCoin, updateCompany } from '@/api/customer'

import { regexp } from '../../../utils/regexp'

export default {
  name: 'Integralsetting',
  props: ['userId'],
  data() {
    return {
      form: {},
      dataList: [],
      drawer: null
    }
  },
  mounted() {
    this.settings()
  },
  methods: {
    settings() {
      getCoin({}).then((res) => {
        if (res.code == 0) {
          this.dataList = res.data
        }
      })
    },
    save() {
      updateCompany({
        assetId: this.form.assetId,
        amount: +this.form.amount,
        remark: this.form.remark,
        userId: this.userId
      }).then((res) => {
        if (res.code == 0) {
          this.$message({
            message: '操作成功',
            type: 'success'
          })
          this.form = {}
        } else {
          this.$message.error(res.message)
        }
      })
    }
  }
}
</script>

<style scoped>
</style>
